using System;
using System.Collections.Generic;
using System.Text;

namespace Chapter8CustomControlsCS
{
    public class MyClass : System.Web.UI.WebControls.WebControl, System.Web.UI.IPostBackDataHandler, System.Web.UI.IPostBackEventHandler
    {
        public delegate void ChangedEventHandler(Object sender, System.EventArgs e);
        public event ChangedEventHandler Changed;
        public event EventHandler MyEvent;
        
                
        bool System.Web.UI.IPostBackDataHandler.LoadPostData(string postDataKey,
                     System.Collections.Specialized.NameValueCollection postCollection)
        {
            if (postCollection[this.UniqueID] != this.ViewState[this.UniqueID].ToString())
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        void System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
        {
         Changed(this, EventArgs.Empty);
        }

        void System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
        {
            if (eventArgument == "MainText")
            {
                MyEvent(this, EventArgs.Empty);
            }
        }

    }
}
